<?php

declare(strict_types=1);

namespace App\CustHub\Mapper;

use App\CustHub\Model\ChSmartTagRule;
use Mine\Abstracts\AbstractMapper;

class ChSmartTagRuleMapper extends AbstractMapper
{
    public function assignModel()
    {
        $this->model = ChSmartTagRule::class;
    }


    /**
     * 获取激活的规则
     * @param int $mainUid
     * @param int $type
     * @return array|\Hyperf\Database\Model\Collection
     */
    public function getActiveRules(int $mainUid,int $type): array|\Hyperf\Database\Model\Collection
    {
        return $this->model::query()
            ->where('main_uid',$mainUid)
            ->where('module',$type)
            ->where('enable',1)
            ->get();
    }
}